/**
 * 项目示例-列表表头
 * Date 2023-11-02 13:52:40
 * 可选参数可参考：https://element-plus.org/zh-CN/component/table.html#table-column-属性
 */

export const exampleColumns = [
  { type: 'index', label: '序号', width: 60, align: 'center' },
  {
    prop: 'className', label: '班次名称', minWidth: 130, align: 'center', ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'classType', label: '班次类型', minWidth: 200, align: 'center', ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        if(cellValue=="S")return '排班制'
        else if(cellValue=="F")return '固定班制'
       else if(cellValue=="C")return '轮班制'
        else return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'classDetail', label: '时间', minWidth: 200,  align: 'center', ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        const json=JSON.parse(eval("("+cellValue+")"))
        if(json.classType=='S'){
          return json.date[0]+'~'+json.date[1]
        }else if(json.classType=='C'){
          return '-'
        }else{
          const list: any[]=[]
          json.date.forEach((item: { dateStr: string | any[]; dayText: any })=>{
            if(item.dateStr&&item.dateStr.length>0){
              list.push(item.dayText)
            }
          })
          return  list.join(',')
        }
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'createTime', label: '更新时间', minWidth: 200, sortable: true,align: 'center', ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  { prop: 'action', label: '操作', align: 'center' }]
